//
//  MXTouchIDPassword.m
//  MXLoginMethodsDomo
//
//  Created by 马彦 on 16/10/9.
//  Copyright © 2016年 MX. All rights reserved.
//

#import "MXTouchIDPassword.h"
#import "MXTouchIDConfig.h"

@implementation MXTouchIDPassword

+(BOOL)isEncrypted {
    NSString *password = [[NSUserDefaults standardUserDefaults] objectForKey:MXTouchID_PASSWORD];
    if (!password) {
        return NO;
    } else {
        return YES;
    }
}

+(BOOL)setNewPassword:(NSString *)password {
    if (password == nil || [password isEqualToString:@""] || [password isEqualToString:@"(null)"]) {
        return NO;
    }
    
    [[NSUserDefaults standardUserDefaults] setObject:password forKey:MXTouchID_PASSWORD];
    [[NSUserDefaults standardUserDefaults] synchronize];
    
    return YES;
}


+ (void)removePassword {
    [[NSUserDefaults standardUserDefaults] removeObjectForKey:MXTouchID_PASSWORD];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

+ (BOOL)isEmptyPassword {
    NSString *password = [[NSUserDefaults standardUserDefaults] objectForKey:MXTouchID_PASSWORD];
    if (password != nil && ![password isEqualToString:@""] && ![password isEqualToString:@"(null)"]) {
        return NO;
    }
    return YES;
}

@end
